package org.aplikator.client.shared.descriptor;

import com.google.gwt.user.client.ui.Widget;
import org.aplikator.client.local.widgets.HasFields;
import org.aplikator.client.local.widgets.RadioButtonWidget;
import org.jboss.errai.common.client.api.annotations.Portable;

import java.io.Serializable;

@SuppressWarnings("serial")
//@Portable
public class RadioButtonDTO extends WidgetPropertyDTOBase implements RenderWidgetAware  {


    @SuppressWarnings("unused")
    public RadioButtonDTO() {//TODO custom marshaller
    }

    public RadioButtonDTO(PropertyDTO property) {
        super(property);
    }

    @Override
    public Widget getWidget(HasFields form) {
        RadioButtonWidget field = new RadioButtonWidget(property.getLocalizedName(), property);
        field.setEnabled(isEnabled());
        if (property.getRefferedThrough() != null) {
            field.setEnabled(false);
        }
        form.registerDataField(field);
        return field;
    }

}
